package org.example;

public class Updater {
    private final UserRepository userRepository;

    private final UserAssembler userAssembler;

    public Updater(UserRepository userRepository, UserAssembler userAssembler) {
        this.userRepository = userRepository;
        this.userAssembler = userAssembler;
    }

    public void update(String name) {
        if (name != null) {
            User user = userAssembler.buildUser(name);
            userRepository.save(user);
        }
    }
}